<?php
//Action Del Message
del_message();
//===================

$mesage = read_message(intval($params[2]));

$cur = time();
$data_time = strtotime($mesage['senddate']);
$num_day =  round(($cur - $data_time)/(24*3600));

$show_num_day = "([Cách] ".$num_day." [ngày trước])";
if($num_day < 1) {
    $show_num_day = "([Hôm nay])";
}
if($num_day == 1) {
    $show_num_day = "([Hôm qua])";
}

$str_cat = "[Hộp thư đến]";
$str_from_to = "[Từ]";
$link_back = get_link("member")."/".$CONFIG_MEMBER_LINK["inbox"];
if($mode=="sent") {
    $str_cat = "[Các thư đã gửi]";
    $str_from_to = "[Đến]";
    $link_back = get_link("member")."/".$CONFIG_MEMBER_LINK["sent"];
}

$show_name = $mesage["username"];
if(is_guest($mesage["username"])) {
    $show_name = $mesage["fullname"];
}

?>
<script type="text/javascript">
    function del_message(){

        re = confirm("[Bạn đã chắc chắn xóa chưa]?");
        if(re==true){
            document.del_mess.submit();
        }
    }
    function fw_message(){

        document.fwform.submit();
    }
</script>
<div class="container">
    <div class="content_mb">

        <?php include_once 'inc/left.php';?>

        <div class="content_mb_r">

            <?php include_once 'inc/post_property_top_center.php';?>
            <div style="margin-left: 20px;">
                <div class="title_mb_r3"><font style="float:left;"><?=$str_cat?></font> </div>

                <div class="bg_title_inbox">
                    <div style="float:right;;padding-right: 10px">
                        <a href="<?=$link_back?>">[Quay lại] <?=$str_cat?></a>
                        <?php

                        if(id_read_back($mesage["mes_id"],$mode)>0) {
                            echo "<a href='#'>|</a>  ";
                            echo "<a href='".get_link("member")."/".$CONFIG_MEMBER_LINK["read"]."/".id_read_back($mesage["mes_id"],$mode)."' title='[Xem thư trước]'>[Xem thư trước]</a>";
                        }

                        if(id_read_next($mesage["mes_id"],$mode)>0) {
                            echo "<a href='#'>|</a>  ";
                            echo "<a href='".get_link("member")."/".$CONFIG_MEMBER_LINK["read"]."/".id_read_next($mesage["mes_id"],$mode)."' title='[Xem thư tiếp]'>[Xem thư tiếp]</a>";
                        }
                        ?>

                    </div>
                    <div class="title_inbox_detail_l">
                        <?php if($mode!="sent") {?>
                        <img src="<?php echo SITE_IMAGES_URL?>/traloi.gif" /><a href="<?=get_link("member")."/".$CONFIG_MEMBER_LINK["reply"]."/".$mesage["username"]?>">[Trả lời]</a>
                            <?php } ?>
                        <img src="<?php echo SITE_IMAGES_URL?>/chuyentiep.gif" /><a href="javascript:void(0);" onclick="fw_message();">[Chuyển tiếp]</a>
                        <img src="<?php echo SITE_IMAGES_URL?>/xoa.gif" /><a href="javascript:void(0);" onclick="del_message();">[Xóa]</a>
                    </div>
                </div>
                <div class="box_inbox">
                    <div class="subject_dt">
                        <div class="subject_dt_l">
                            <?=$str_from_to?>: <b><?php echo $show_name." (".$mesage["email"].")"?></b><br />
							[Ngày gửi]: <?php echo get_my_date($mesage['senddate'])." ".$show_num_day;?>
                        </div>

                    </div>

                    <div class="content_details">
                        <?php echo "<h2>".$mesage["title"]."</h2><br />".$mesage["content"];?>
                    </div>
                </div>

                <form name="del_mess" action="" method="post"><input type="hidden" name="mode" value="<?=$mode?>" /><input type="hidden" name="mes_id" value="<?=$mesage["mes_id"]?>" /></form>
                <form name="fwform" action="<?=get_link("member")."/".$CONFIG_MEMBER_LINK["forward"]?>" method="post"><input type="hidden" name="fwsubject" value="<?=htmlentities_utf8($mesage["title"])?>" /><input type="hidden" name="fwcontent" value="<?=htmlentities_utf8($mesage["content"])?>" /></form>

                <div class="bg_title_inbox">
                    <div style="float:right;padding-right: 10px">
                        <a href="<?=$link_back?>">[Quay lại] <?=$str_cat?></a>
                        <?php

                        if(id_read_back($mesage["mes_id"],$mode)>0) {
                            echo "<a href='#'>|</a>  ";
                            echo "<a href='".get_link("member")."/".$CONFIG_MEMBER_LINK["read"]."/".id_read_back($mesage["mes_id"],$mode)."' title='[Xem thư trước]'>[Xem thư trước]</a>";
                        }

                        if(id_read_next($mesage["mes_id"],$mode)>0) {
                            echo "<a href='#'>|</a>  ";
                            echo "<a href='".get_link("member")."/".$CONFIG_MEMBER_LINK["read"]."/".id_read_next($mesage["mes_id"],$mode)."' title='[Xem thư tiếp]'>[Xem thư tiếp]</a>";
                        }
                        ?>

                    </div>
                    <div class="title_inbox_detail_l">
                        <?php if($mode!="sent") {?>
                        <img src="<?php echo SITE_IMAGES_URL?>/traloi.gif" /><a href="<?=get_link("member")."/".$CONFIG_MEMBER_LINK["reply"]."/".$mesage["username"]?>">[Trả lời]</a>
                            <?php } ?>
                        <img src="<?php echo SITE_IMAGES_URL?>/chuyentiep.gif" /><a href="javascript:void(0);" onclick="fw_message();">[Chuyển tiếp]</a>
                        <img src="<?php echo SITE_IMAGES_URL?>/xoa.gif" /><a href="javascript:void(0);" onclick="del_message();">[Xóa]</a>
                    </div>
                </div>


            </div>
        </div>

    </div>
</div>